﻿using VirtualTournaments.DataAccess.SqlServer.DataProxies;

namespace VirtualTournaments.DataAccess.SqlServer.DataMappers
{
	internal sealed class ThreeWaysBetTargetsDataMapper : AbstractDataMapper<SqlServer.ThreeWaysBetTarget, Business.Bets.ThreeWaysBetTarget, DataProxies.ThreeWaysBetTargetDataProxy>
	{
		#region Singleton implementation

		private static ThreeWaysBetTargetsDataMapper _instance = null;
		private static object _instanceLocker = new object();

		private ThreeWaysBetTargetsDataMapper() { }

		public static ThreeWaysBetTargetsDataMapper Instance
		{
			get
			{
				if (_instance == null)
				{
					lock (_instanceLocker)
					{
						if (_instance == null)
						{
							_instance = new ThreeWaysBetTargetsDataMapper();
						}
					}
				}
				return _instance;
			}
		}

		#endregion

		internal override VirtualTournamentsDataContext GetDataContext()
		{
			return VirtualTournamentsDataContext.Instance;
		}

		internal override System.Data.Linq.Table<ThreeWaysBetTarget> GetDataTable()
		{
			return GetDataContext().ThreeWaysBetTargets;
		}

		internal override Business.Bets.ThreeWaysBetTarget DataObject2BusinessObject(SqlServer.ThreeWaysBetTarget dataObject)
		{
			Business.Tournaments.Match match = MatchesDataMapper.Instance.GetOneAsBusinessObject(_match => _match.MatchId == dataObject.MatchId);
			return new ThreeWaysBetTargetDataProxy(dataObject, match);
		}

		internal override void BusinessObject2DataObject(Business.Bets.ThreeWaysBetTarget bizBetTarget, SqlServer.ThreeWaysBetTarget dataBetTarget)
		{
			throw new System.NotImplementedException();
		}

		internal override void DataProxy2DataObject(ThreeWaysBetTargetDataProxy dataProxy, SqlServer.ThreeWaysBetTarget dataObject)
		{
			throw new System.NotImplementedException();
		}
	}
}
